import displayDate from "./components/display/date/display-date.vue";
import displayInput from "./components/display/input/display-input.vue";
import displayRadio from "./components/display/radio/display-radio.vue";
import displaySelect from "./components/display/select/display-select.vue";
import displayTitle from "./components/display/title/display-title.vue";

import configDate from "./components/display/date/config-date.vue";
import configInput from "./components/display/input/config-input.vue";
import configRadio from "./components/display/radio/config-radio.vue";
import configSelect from "./components/display/select/config-select.vue";
import configTitle from "./components/display/title/config-title.vue";

import { FormConfigType, FormType } from "./type.d";

export const displayComponents = {
  [FormType.FORM_TYPE_DATE]: displayDate,
  [FormType.FORM_TYPE_INPUT]: displayInput,
  [FormType.FORM_TYPE_RADIO]: displayRadio,
  [FormType.FORM_TYPE_SELECT]: displaySelect,
  [FormType.FORM_TYPE_TITLE]: displayTitle,
};

export const configComponents = {
  [FormConfigType.FORM_CONFIG_DATE]: configDate,
  [FormConfigType.FORM_CONFIG_INPUT]: configInput,
  [FormConfigType.FORM_CONFIG_RADIO]: configRadio,
  [FormConfigType.FORM_CONFIG_SELECT]: configSelect,
  [FormConfigType.FORM_CONFIG_TITLE]: configTitle,
};
// 根据组件类型，返回组件配置类型
export function componentTypeToConfig(componentType: FormType): FormConfigType {
  switch (componentType) {
    case FormType.FORM_TYPE_TITLE:
      return FormConfigType.FORM_CONFIG_TITLE;
    case FormType.FORM_TYPE_DATE:
      return FormConfigType.FORM_CONFIG_DATE;
    case FormType.FORM_TYPE_INPUT:
      return FormConfigType.FORM_CONFIG_INPUT;
    case FormType.FORM_TYPE_RADIO:
      return FormConfigType.FORM_CONFIG_RADIO;
    case FormType.FORM_TYPE_SELECT:
      return FormConfigType.FORM_CONFIG_SELECT;
    default:
      throw new Error("没有对应的配置类型");
  }
}
